<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt"%>
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>

        </title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="format-detection" content="telephone=no">
        <link rel="stylesheet" href="../css/x-admin.css" media="all">
        <link rel="stylesheet" href="../css/pag.css" media="all">
        <link rel="stylesheet" href="../lib/layui/css/layui.css" media="all">
    </head>
    <body>
        <div class="x-nav">
            <span class="layui-breadcrumb">
              <a><cite>首页</cite></a>
              <a><cite>采购管理</cite></a>
              <a><cite>采购单创建</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"  href="javascript:location.replace(location.href);" title="刷新"><i class="layui-icon" style="line-height:30px">ဂ</i></a>
        </div>
        <div class="x-body">

            <form id="form1"  action="##" method="post" onsubmit="return false" class="layui-form" >
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">采购单编号</label>
                        <div class="layui-input-inline">
                            <input type="text" name="cgNo" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">采购单名称</label>
                        <div class="layui-input-inline">
                            <input  type="text" name="cgCgdmc" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">采购状态</label>
                        <div class="layui-input-inline">
                            <select name="cgCgzt" >
                                <option value="">请选择采购状态</option>
                                <option value="0">未入库</option>
                                <option value="1">入库</option>
                            </select>
                        </div>
                    </div>


                </div>

                <div class="layui-form-item">


                    <div class="layui-inline">
                        <label class="layui-form-label">审核状态</label>
                        <div class="layui-input-inline">
                        <select name="cgShzt" >
                                <option value="">请选择状态</option>
                                <option value="0">未提交</option>
                                <option value="1">审核中</option>
                                <option value="2">审核通过</option>
                                <option value="3">已放弃</option>
                        </select>
                    </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">审核备注</label>
                        <div class="layui-input-inline">
                            <input  type="text" name="cgShbz" autocomplete="off" class="layui-input">
                        </div>
                    </div>

                </div>


                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">开始时间</label>
                        <div class="layui-input-block">
                            <input style="width: 190px"  name="cgKssj" id="test1" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">结束时间</label>
                        <div class="layui-input-block">
                            <input style="width: 190px"  name="cgJssj" id="test2" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>

                <div class="layui-input-inline " style="width: 90px">
                    <button class="layui-btn" onclick="create()">
                        <i class="layui-icon" style="font-size: 20px; "></i> 创建采购单
                    </button>
                </div>

            </form>

        </div>
        <script src="../lib/layui/layui.js" charset="utf-8"></script>
        <script src="../lib/layui/layui.all.js" charset="utf-8"></script>
        <script src="../js/x-layui.js" charset="utf-8"></script>
        <script src="../js/jquery2.js" charset="utf-8"></script>
        <script src="../js/js.js" charset="utf-8"></script>
        <script>
            function create() {
                $.ajax({
                    //几个参数需要注意一下
                    type: "POST",//方法类型
                    dataType: "json",//预期服务器返回的数据类型
                    url: "${pageContext.request.contextPath}/createYpcg" ,//url
                    data: $('#form1').serialize(),
                    success: function (result) {
                        console.log(result);//打印服务端返回的数据(调试用)
                        if (result.resultCode == 200) {
                            alert("SUCCESS");
                           var addIndex = parent.layer.getFrameIndex(window.name);
                            window.parent.layer.close(addIndex);
                            //刷新父页面的table
                            window.parent.tableYpcgIns.reload();
                        }
                        ;
                    },
                    error : function() {
                        alert("异常！");
                    }
                });
            }
            layui.use('form', function(){
                var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功

                //……

                //但是，如果你的HTML是动态生成的，自动渲染就会失效
                //因此你需要在相应的地方，执行下述方法来手动渲染，跟这类似的还有 element.init();
                form.render();
            });
            layui.use('laydate', function(){
                var laydate = layui.laydate;

                //执行一个laydate实例
                laydate.render({
                    elem: '#test1'
                    ,type: 'datetime'
                });
                laydate.render({
                    elem: '#test2' //指定元素
                    ,type: 'datetime'
                });
            });
        </script>
    </body>
</html>